
import 'package:enjoy_push_three/pages/login/index.dart';
import 'package:enjoy_push_three/pages/notice/index.dart';
import 'package:enjoy_push_three/pages/profile/index.dart';
// import 'package:enjoy_push_three/pages/tab_bar_page.dart';
import 'package:enjoy_push_three/utils/token.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    routes: {
      // '/': (context) => const TabBarPage(),
      '/detail': (context) => const NoticeDetail(),
    },
    // 登录拦截
    onGenerateRoute:(settings){
    final tokenManager = TokenManager();
    final token = tokenManager.getToken() ?? '';
    if(token.isEmpty && settings.name != '/login'){
      return MaterialPageRoute(builder: (context)=>const LoginPage());
    }
    if(settings.name == '/profile') {
   return MaterialPageRoute(builder: (context)=> ProfilePage());
    }
    return null;
    },
    initialRoute: '/',

  ));
}

